package com.mjl.shops.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.mjl.shops.R;
import com.mjl.shops.base.ShopApp;

import java.util.Random;

public class CommUtils {

    public static final String UserId = "USERID";

    public static final String color_05000000 = "#05000000";

    public static final String HISTORY = "#HISTORY";


    private static Toast toast;

    public static void setToast(String str){

        Context contexts = ShopApp.getInstance();
        View view = LayoutInflater.from(contexts).inflate(R.layout.toast_layout,null,false);
        TextView t = view.findViewById(R.id.toast_tv);
        if (StringUtils.strEmpty(str)){
            t.setText(str);
        }else{
            t.setText("");
        }

        if (toast == null){
            toast = new Toast(contexts);
        }
        toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 70);
        //设置显示时间
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(view);
        toast.show();
    }

    public static int getRandom(int index){
        Random ra =new Random();
        return ra.nextInt(index);
    }
}

